package com.cskaoyan.market.util;

import java.io.UnsupportedEncodingException;

/**
 * @Author 远志 zhangsong@cskaoyan.onaliyun.com
 * @Date 2024/7/3 10:32
 * @Version 1.0
 */
public class DigestUtils {

    public static String md5(String str) throws UnsupportedEncodingException {
        return org.springframework.util.DigestUtils.md5DigestAsHex(str.getBytes("utf-8"));
    }

    public static String twiceMd5(String str) throws UnsupportedEncodingException {
        String md5 = org.springframework.util.DigestUtils.md5DigestAsHex(str.getBytes("utf-8"));
        return org.springframework.util.DigestUtils.md5DigestAsHex(md5.getBytes("utf-8"));
    }

    //密码6位  salt也是6位  交叉在一起
    public static String md5WithSalt(String str, String salt) throws UnsupportedEncodingException {
        return org.springframework.util.DigestUtils.md5DigestAsHex((str + salt).getBytes("utf-8"));
    }
}
